<?php
require_once('../../conf/config.php.inc');
require_once(SYBMAS_LIB_PATH.'/liblogin.php.inc');
require_once(SYBMAS_LAYOUT_PATH.'/layout.php.inc');
require_once(SYBMAS_LIB_PATH.'/libsybmas.php.inc');
require_once(SYBMAS_LAYOUT_PATH.'/menu.php.inc');
require_once('libtablas.php.inc');
verificar_inicio_sesion();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css"
	href="<?php echo LAYOUT_URI?>/sybmasstyle.css">
<script src="<?php echo LAYOUT_URI?>/jquery-1.2.1.min.js"
	type="text/javascript"></script>
<script src="<?php echo LAYOUT_URI?>/menu-collapsed.js"
	type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
	href="<?php echo LAYOUT_URI?>/style.css" >
<link rel="stylesheet" type="text/css"
	href="<?php echo JAVASCRIPT_URI?>/tabs/tabs.css">
<script src="<?php echo JAVASCRIPT_URI?>/tabs/tabs.js"
	type="text/javascript"></script>
<script type="text/javascript" src="<?php echo JAVASCRIPT_URI?>/commons.js"></script>
<script type="text/javascript" src="tabla.js"></script>
<title>.:: Sybmas - Modificar Logins</title>
<!--[if lt IE 8]>
   <style type="text/css">
   li a {display:inline-block;}
   li a {display:block;}
   </style>
   <![endif]-->      
</head>
<body>
<script src="<?php echo JAVASCRIPT_URI?>/tooltip/wz_tooltip.js"
	type="text/javascript"></script>
<center>
<div id="container">
<div id="header"><?php generar_header();?></div>
<div id="scene">
<div id="modulos">
<ul id="menu" style="width: 150px;">
<?php generar_menu();?>
</ul>
</div>

<div id="title">Modificar Logins</div>
<div id="main">
<?php 
$id=$_GET['suid'];
?> 
<?php
$sybuser_connection=start_default_sybuser_connection();
	$query="SELECT suid,name,dbname,fullname from master..syslogins WHERE suid=$id";
	$result=sybase_query($query,$sybuser_connection);
	$data=sybase_fetch_array($result);
	$nomlogin=$data['name'];
	$fullact=$data['fullname'];	
	$cvesuid=$data['suid'];		
?>

<?php 			  
  			function rolactual(){
  			global $cvesuid;
  			sybase_min_server_severity(11);	  			 			  			
  			$sybmas_connection=start_sybmas_connection();	
  			$query="SELECT r.name ". 
         		   "FROM master..syssrvroles r,master..syslogins l,master..sysloginroles sl ". 
         		   "WHERE sl.suid=$cvesuid  ". 
         		   "AND r.srid=sl.srid  ". 
         		   "GROUP BY r.name";
  			//echo "$query<br>";
  			//echo "<select name='rolactual' id='rolactual'>";
			$resultado=sybase_query($query);
	  			while ($fila=sybase_fetch_row($resultado)){	
	  			echo "<ul><li><b>";				
				echo $fila[0];
				echo "<br>";
				echo "</ul></li></b>";
	  		}				
		}
		?>
<div id="tab_panel">
<div id="tab_header">
<ul>
	
	<li id="selected"><a href="#" id="ctl_tabgeneral" onclick="showTab(this.id,0)"><?php echo $nomlogin?></a></li>
	<li><a href="#" id="ctl_tabroles" onclick="showTab(this.id,1)">Roles</a></li>		
	<li><a href="#" id="ctl_tabfullname" onclick="showTab(this.id,2)">Fullname</a></li>
	<li><a href="#" id="ctl_tabpassword" onclick="showTab(this.id,3)">Password</a></li>		
</ul>
</div>
<div id="tab_content">

<div class="tab_scene" style="display: block">

<table width="80%" border="1">
	<caption><b>Informacion general del Login</b></caption>
	<tr>
		<th bgcolor="#8BA7C2">suid</th>
		<td ><?php echo $data['suid']?></td>
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">name</th>	
		<td><?php echo $data['name']?></td>
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">dbname</th>
		<td><?php echo $data['dbname']?></td>
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">fullname</th>
		<td><?php echo $data['fullname']?></td>
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">Roles Actuales del Login</th>
	    <td>
		<?php 
		  rolactual();
		?>		
		</td>	
	</tr>
</table>
</div><!-- tab_scene --> 
<div class="tab_scene">
<div class="controls">
<form method="POST" action="modificarRol.php" target="constraints_dialog" onsubmit="postDialog('constraints_dialog')">
<input type="hidden" name="otorgarol" value="<?php echo $otorgarol?>">	
<input type="hidden" name="otorgarol" value="<?php echo $revocarol?>">
<input type="hidden" name="rol" value="<?php echo $rol?>">
<input type="hidden" name="login" value="<?php echo $nomlogin?>">
<input type="hidden" name="cvesuid" value="<?php echo $cvesuid?>">
 <input type="submit" value="Otorgar o Revocar Roles">		
</form>
</div>
<hr>	
<table width="80%" border="1">
  <caption>Roles</caption>
	
	<tr>	    
		<th bgcolor="#8BA7C2">suid</th>	 	
		<td><?php echo $data['suid']?></td>
	 </tr>
	 <tr>					  		
		<th bgcolor="#8BA7C2">name</th>
		<td><?php echo $data['name']?></td>
	 </tr>
	 <tr>				
		<th bgcolor="#8BA7C2">dbname</th>
		<td><?php echo $data['dbname']?></td>
	</tr>
	<tr>	
		<th bgcolor="#8BA7C2">fullname</th>
		<td><?php echo $data['fullname']?></td>			
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">Roles Actuales del Login</th>
	    <td>
		<?php 
		  rolactual();
		?>		
		</td>	
	</tr>
	<?php
		while($data=sybase_fetch_array($result)){			
			?>
		<tr>
			<td><?php echo $data['suid']?></td>
			<td><?php echo $data['name']?></td>
			<td><?php echo $data['dbname']?></td>
			<td><?php echo $data['fullname']?></td>
			
		</tr>
		<?php 
		  rolactual();
		?>	
		
		<?php
		}		
		?>			
</table>
</div><!-- tab_scene -->

<?php
$sybuser_connection=start_default_sybuser_connection();
	$query="SELECT suid,name,dbname,fullname from master..syslogins WHERE suid=$id";
	//echo "$query<br>";
	$result=sybase_query($query,$sybuser_connection);
	$data=sybase_fetch_array($result);
	$nomlogin=$data['name'];
	$fullact=$data['fullname'];
	$cvesuid=$data['suid'];		
?>
<div class="tab_scene">

<div class="controls">
<form method="POST" action="modificar.php" target="constraints_dialog" onsubmit="postDialog('constraints_dialog')">
<input type="hidden" name="fullname" value="<?php echo $fullname?>">	
<input type="hidden" name="nomlogin" value="<?php echo $nomlogin?>">
<input type="hidden" name="fullact" value="<?php echo $fullact?>">
 <input type="submit" value="Cambiar Fullname">	
</form>
</div>
<hr>
	
<table width="80%" border="1">
  <caption>Fullname</caption>
	<tbody>
	 <tr>	    
		<th bgcolor="#8BA7C2">suid</th>
		<td ><?php echo $data['suid']?></td>	 			
	 </tr>
	 <tr>					  		
		<th bgcolor="#8BA7C2">name</th>
		<td><?php echo $data['name']?></td>
	 </tr>
	 <tr>				
		<th bgcolor="#8BA7C2">dbname</th>
		<td><?php echo $data['dbname']?></td>
	</tr>
	<tr>	
		<th bgcolor="#8BA7C2">fullname</th>
		<td><?php echo $data['fullname']?></td>			
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">Roles Actuales del Login</th>
	    <td>
		<?php 
		  rolactual();
		?>		
		</td>	
	</tr>
	<?php
		while($data=sybase_fetch_array($result)){			
			?>
		<tr>
			<td><?php echo $data['suid']?></td>
			<td><?php echo $data['name']?></td>
			<td><?php echo $data['dbname']?></td>
			<td><?php echo $data['fullname']?></td>
			
		</tr>
		<?php
		}		
		?>			
</tbody>		
</table>
</div><!-- tab_scene -->

<?php
$sybuser_connection=start_default_sybuser_connection();
	$query="SELECT suid,name,dbname,fullname from master..syslogins WHERE suid=$id";
	$result=sybase_query($query,$sybuser_connection);
	$data=sybase_fetch_array($result);
	$nomlogin=$data['name'];
	$fullact=$data['fullname'];		
?>

<div class="tab_scene">
<div class="controls">
<form method="POST" action="modpass.php" target="constraints_dialog" onsubmit="postDialog('constraints_dialog')">
<input type="hidden" name="login" value="<?php echo $nomlogin?>">		
 <input type="submit" value="Cambiar Password">		
</form>
</div>
<hr>
	
<table width="80%" border="1">
  <caption>Password</caption>
	<tbody>
	 <tr>	    
		<th bgcolor="#8BA7C2">suid</th>
		<td ><?php echo $data['suid']?></td>	 			
	 </tr>
	 <tr>					  		
		<th bgcolor="#8BA7C2">name</th>
		<td><?php echo $data['name']?></td>
	 </tr>
	 <tr>				
		<th bgcolor="#8BA7C2">dbname</th>
		<td><?php echo $data['dbname']?></td>
	</tr>
	<tr>	
		<th bgcolor="#8BA7C2">fullname</th>
		<td><?php echo $data['fullname']?></td>			
	</tr>
	<tr>
		<th bgcolor="#8BA7C2">Roles Actuales del Login</th>
	    <td>
		<?php 
		  rolactual();
		?>		
		</td>	
	</tr>
	<?php
		while($data=sybase_fetch_array($result)){			
			?>
		<tr>
			<td><?php echo $data['suid']?></td>
			<td><?php echo $data['name']?></td>
			<td><?php echo $data['dbname']?></td>
			<td><?php echo $data['fullname']?></td>
			
		</tr>
		<?php
		}		
		?>			
</tbody>		
</table>
</div><!-- tab_scene -->
 
</div>
</div>
<!-- main --></div>
<!-- scene -->
</div>
 <?php generar_footer();?></div>
</center>
</body>
</html> 